﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Kokomo.Mirror.CliMetadata
{
	class StringRefPropertyDescriptor : MetadataRowPropertyDescriptor
	{
		public StringRefPropertyDescriptor(
			PropertyDescriptor baseDescriptor,
			MetadataContainer container
			)
			: base(baseDescriptor, container)
		{
		}

		public override object GetValue(object component)
		{
			ICustomTypeDescriptor descriptor = component as ICustomTypeDescriptor;
			StringRef stringRef = (StringRef)this.BaseDescriptor.GetValue(descriptor.GetPropertyOwner(this));
			string str = this.Container.GetString(stringRef) ?? "<null>";
			return str;
		}
		public override Type PropertyType
		{
			get { return typeof(string); }
		}
	}
}
